import 'package:flutter/material.dart';

//  修改主题
class ThemePage extends StatefulWidget {
  const ThemePage({super.key});

  @override
  State<ThemePage> createState() => _ThemePageState();
}

class _ThemePageState extends State<ThemePage> {
  var _brightness = Brightness.dark;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '修改主题',
      theme: ThemeData(
        useMaterial3: true,
        brightness: _brightness,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text('修改主题'),
          leading: BackButton(),
        ),
        body: Container(
          child: TextButton(
              onPressed: () {
                setState(() {
                  if (_brightness == Brightness.dark) {
                    _brightness = Brightness.light;
                  } else {
                    _brightness = Brightness.dark;
                  }
                });

              },
              child: Text('修改主题')),
        ),
      ),
    );
  }
}
